torque.stores['torrent.files'] = new Ext.data.Store({
    id: 'TorqueTorrentFilesStore',
    autoLoad: true,
    proxy: new Ext.data.HttpProxy({
        url: torque.paths.root+'/files/index',
        method: 'POST'
    }),
    reader: new Ext.data.JsonReader(
        {
            root: 'data',
            totalProperty: 'items',
        },
        [
            {name: 'name', type: 'string', mapping: 'name'},
            {name: 'path', type: 'string', mapping: 'path'},
            {name: 'size', type: 'int', mapping: 'size'},
            {name: 'base64', type: 'string', mapping: 'base64'},
            {name: 'extension', type: 'string', mapping: 'extension'},
            {name: 'type', type: 'string', mapping: 'type'}
        ]
    ),
    sortInfo: {field: 'type', direction: 'DESC'}
});

TorqueTorrentFiles = new Ext.grid.ColumnModel([
    {
        header: '',
        dataIndex: 'extension',
        hidden: false,
        hideable: false,
        menuDisabled: true,
        resizable: false,
        sortable: false,
        renderer: torque.converter.img.extension,
        width:1,
    },
    {
        header: 'Name',
        dataIndex: 'name',
        width:80,
        hidden: false,
    },
    {
        header: 'Size',
        dataIndex: 'size',
        width:20,
        align: 'right',
        hidden: false,
        renderer: torque.converter.size.best,
    }
]);

torque.panels['files'] = new Ext.grid.GridPanel({
    store: torque.store('torrent.files'),
    cm: TorqueTorrentFiles,
    selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
    title: 'Files',
    viewConfig: {
        forceFit: true,
    },
    iconCls: 'icon-files',
    border: false,
});
